import React, { useState, useEffect } from 'react';
import '../sass/Right.scss'
import Time from './Time';
import dayjs from 'dayjs';
const Right = () => {
    const ZHOU = [
        '星期日',
        '星期一',
        '星期二',
        '星期三',
        '星期四',
        '星期五',
        '星期六',
    ];
    const [s, setS] = useState('');
    const [day, setDay] = useState('');
    const [zhou, setZhou] = useState('');

    useEffect(() => {
        setInterval(() => {
            const date = dayjs();
            const sound = date.format('HH:mm:ss');
            const day = date.format('YYYY/MM/DD');
            const time = date.day();
            setZhou(ZHOU[time]);
            setS(sound);
            setDay(day);
        }, 1000);
        return () => { };

    }, [])
    return (
        <div id='rigth'>
            <div className="R1"><span>当前时间：</span><span>{day}</span><span>{s}</span><span>{zhou}</span></div>
            <div className='R2'>
                <p>128</p>
                <span>在线访客数</span>
                <div className='R3'><span><Time></Time></span>秒之后更新数据</div>
            </div>
        </div >
    );
};

export default Right;